package com.xuxu.blog.exception;

import lombok.AllArgsConstructor;
import lombok.Getter;
import com.xuxu.blog.enums.StatusCodeEnum;
import static com.xuxu.blog.enums.StatusCodeEnum.FAIL;
/**
 * @className: ServiceException
 * @author: Maxuxu
 * @date: 2022/8/25 23:56
 * @description:
 */
@Getter
@AllArgsConstructor
public class ServiceException extends RuntimeException {
    /**
     * 错误码,从枚举类中导入静态的状态
     */
    private Integer code = FAIL.getCode();
    /**
     * 错误信息
     *
     * @param message
     */
    private final String message;

    public ServiceException(String message) {
        this.message = message;
    }

    public ServiceException(StatusCodeEnum statusCodeEnum) {
        this.code = statusCodeEnum.getCode();
        this.message = statusCodeEnum.getDesc();
    }


}
